package com.onesports.intelligent.k12.polarlight.controller.organization.order;

import cn.gjing.excel.executor.ExcelFactory;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.organization.OrgEvaluateDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.order.OrderByIdVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.order.OrgOrderEvaluatePageVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.order.OrganAndCampusVO;
import com.onesports.intelligent.k12.polarlight.service.order.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @author chenrl
 **/
@Api(tags = "机构端-教务管理-服务评价")
@RestController
@RequiredArgsConstructor
@RequestMapping(ApiPathConstants.ORG_EVALUATE)
public class OrgEvaluateController {

    private final OrderService orderService;

    @ApiOperation("分页查询服务评价")
    @GetMapping("/select-page")
    public ResponseEntity<IPage<OrgOrderEvaluatePageVO>> selectPage(@Valid OrgEvaluateDTO orgEvaluateDTO) {
        return ResultUtil.success(orderService.selectOrgEvaluatePage(new Page<OrgOrderEvaluatePageVO>(orgEvaluateDTO.getPage(),orgEvaluateDTO.getRow()),orgEvaluateDTO));
    }
    @ApiOperation("订单导出")
    @GetMapping("/export")
    public void export(HttpServletResponse response, OrgEvaluateDTO dto) {
        IPage<OrgOrderEvaluatePageVO> orderEvaluatePageVOIPage = orderService.selectOrgEvaluatePage(new Page<>(1, Integer.MAX_VALUE), dto);
        ExcelFactory.createWriter(OrgOrderEvaluatePageVO.class, response)
                .write(orderEvaluatePageVOIPage.getRecords()).flush();
    }
    @ApiOperation("根据id查询服务评价信息")
    @GetMapping("/select-by-id")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderNo", value = "订单id", required = true, dataType = "String", paramType = "query"),
    })
    public ResponseEntity<OrderByIdVO> selectById(String orderNo) {
        return ResultUtil.success(orderService.selectById(orderNo));
    }
    @ApiOperation("查询页下拉-团队校区课程")
    @GetMapping("/select-up")
    public ResponseEntity<OrganAndCampusVO> selectByOAndC() {
        return ResultUtil.success(orderService.selectByOAndCAndC());
    }
}













